package com.jackstraw.jack_base.mq.common.entity;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * 返回体
 *
 * @param <T>
 */
@Data
@Slf4j
public class MQSendResult<T> implements Serializable {
    private static final long serialVersionUID = 1106025769685520085L;
    private T t;

    private String resultCode;

    private String resultMessage;

    public MQSendResult() {
        this.resultCode = "00";
        this.resultMessage = "SUCCESS";
    }

    public T getT() {
        return t;
    }

    public MQSendResult<T> setT(T t) {
        this.t = t;
        return this;
    }

    public String getResultCode() {
        return resultCode;
    }

    public MQSendResult<T> setResultCode(String resultCode) {
        this.resultCode = resultCode;
        return this;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public MQSendResult<T> setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
        return this;
    }

    public MQSendResult(String resultCode, String resultMessage) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }

    public MQSendResult(T t) {
        this();
        this.t = t;
    }

    public MQSendResult(String resultCode, String resultMessage, T t) {
        this.t = t;
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }

    /**
     * 拿到默认的返回结果
     *
     * @return
     */
    public static MQSendResult ERROR() {
        return new MQSendResult("01", "ERROR");
    }

    /**
     * 拿到默认的返回结果
     *
     * @return
     */
    public static MQSendResult DEFAULT() {
        return new MQSendResult();
    }

    /**
     * 拿到默认的返回结果
     *
     * @return
     */
    public static <T> MQSendResult<T> DEFAULT(Class<T> tClass) {
        return new MQSendResult<T>();
    }
}
